<%--                                                                       --%>
<%-- Copyright (c) 2005 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%
  String ctxPath = request.getContextPath();
%>

<script language="JavaScript">
 
//
//
//
function doDivMappingsMultiEdit(programId) {
  document.epChannelDivMappingsViewForm.programId.value = "";
  if (0 != programId) {
    document.epChannelDivMappingsViewForm.programId.value = programId;
  }
  document.epChannelDivMappingsViewForm.action = '<c:url value="/ep/channelDivMappingsMultiEdit.do?createNew=0"/>';
  document.epChannelDivMappingsViewForm.submit();
}

//
//
//
function doDivMappingCreate() {
  document.epChannelDivMappingsViewForm.action = '<c:url value="/ep/channelDivMappingsMultiEdit.do?createNew=1"/>';
  document.epChannelDivMappingsViewForm.submit();
}

//
//
//
function doDivMappingRemove(programId) {

  if (doDivMappingConfirmDelete())
  {
  }
  else {
	  return false;
  }
  document.epChannelDivMappingsViewForm.programId.value = "";
  if (0 != programId) {
    document.epChannelDivMappingsViewForm.programId.value = programId;
  }
  document.epChannelDivMappingsViewForm.action = '<c:url value="/ep/channelDivMappingsRemove.do"/>';
  document.epChannelDivMappingsViewForm.submit();
}

function doDone(form) {
  form.action = "<c:url value="/ep/cancel.do"/>";
  form.submit();
}

function doDivMappingConfirmDelete() {
  return confirm('<bean-el:message key="ep.channel.div.mappings.delete" bundle="ep.messages"/>');
}

<%@ include file="/mc/common/jsutils.jsp" %>

</script>

<!-- Prepare Action icons -->
<c:set var="editImg">
<img src="<%= request.getContextPath() %>/ep/images/action/icon_edit.gif" width="15" height="15" class="actionIcon" border="0" alt='<bean-el:message key="image.alt.edit" bundle="ep.messages"/>' title='<bean-el:message key="image.alt.edit" bundle="ep.messages"/>' >
</c:set>
<c:set var="removeImg">
<img src="<%= ctxPath %>/ep/images/action/icon_remove.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.remove" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.remove" bundle="ep.messages"/>">
</c:set>

<!-- Prepare page title -->
<c:set var="pageTitle">
<bean-el:message key="ep.channel.view.page.title" bundle="ep.messages" arg0="${epChannelDivMappingsView.map.name}"/>
</c:set>
<c:set var="editable" value="${epChannelDivMappingsView.map.editable}"/>

<!-- Display main body -->
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
	  <!-- Page title -->
      <div class="pageTitle">
        <c:out value="${pageTitle}"/>
      </div> 
	  <!-- Tabs -->
      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>
      <%@include file="/mc/common/pagetab.jsp" %>

<!-- DivMappings Section -->
      <div class="breadcrumb">
      <c:if test="${not empty epChannelDivMappingsView.map.breadcrumbs}">
        <c:forEach var="channel" items="${epChannelDivMappingsView.map.breadcrumbs}" varStatus="index">
          <c:url var="browseUrl" value="/ep/channelBrowse.do">
            <c:param name="channelId" value="${channel.map.id}"/>
          </c:url>
          <c:if test="${index.count > 1}"><bean-el:message key="ep.breadcrumb.delimiter" bundle="ep.messages"/>&nbsp;</c:if><a href="<c:out value="${browseUrl}"/>"><c:out value="${channel.map.name}"/></a>
        </c:forEach>
      </c:if>
      </div>
<c:if test="${epChannelDivMappingsView.map.id != 0}">
	  <!-- View form -->
	  <form name="epChannelDivMappingsViewForm" method="post">
      <html-el:hidden property="channelId" value="${epChannelDivMappingsView.map.id}"/>
      <input type="hidden" name="programId"/>
      <input type="hidden" name="ctx.f" value="<c:out value="${requestScope['ctx.f']}"/>"/>


	  <div class="pageSubtitle">
        <span class="left"><bean-el:message key="ep.channel.div.mappings" bundle="ep.messages"/></span>
        <span class="right">
<c:if test="${epChannelDivMappingsView.map.editable}">
        <input type="button" class="globalButton" value="<bean-el:message key="button.new.div.mapping" bundle="ep.messages"/>" onclick="doDivMappingCreate();">
</c:if>
        </span>
      </div>

<!-- Select all, Edit, and Remove buttons -->
<c:if test="${not empty epChannelDivMappingsView.map.divMappings}">
      <div class="globalButtonWrap">
        <input type="button" name="selectAllPrograms" class="globalButton" value="<bean-el:message key="button.selectAll" bundle="ep.messages"/>"
          onclick="check(this.form.mappings, this);">
        <input type="button" class="globalButton" value="<bean-el:message key="button.remove" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.mappings, '<bean-el:message key="ep.channel.div.mappings.atLeastOne" bundle="ep.messages"/>')) doDivMappingRemove(0);">
      </div>
</c:if>

	  <!-- DIV mappings -->
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        <tr class="listHeader">
          <th id="Checkboxes" width="5%">&nbsp;</th>
          <th id="DivName" align="left" width="20%"><bean-el:message key="ep.channel.div.mappings.name" bundle="ep.messages"/></th>
          <th id="ProgramName" align="left" width="30%"><bean-el:message key="ep.channel.div.mappings.program" bundle="ep.messages"/></th>
          <th id="Actions" align="left" width="15%" nowrap><bean-el:message key="ep.header.actions" bundle="ep.messages"/></th>
		</tr>
<c:forEach var="item" items="${epChannelDivMappingsView.map.divMappings}" varStatus="index">

        <c:url var="editUrl" value="/ep/channelDivMappingsMultiEdit.do">
            <c:param name="createNew" value="0"/>
            <c:param name="programId" value="${item.map.programId}"/>
            <c:param name="channelId" value="${epChannelDivMappingsView.map.id}"/>
			<c:param name="divName" value="${item.map.divName}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	    </c:url>
        <c:url var="deleteUrl" value="/ep/channelDivMappingsRemove.do">
            <c:param name="programId" value="${item.map.programId}"/>
            <c:param name="channelId" value="${epChannelDivMappingsView.map.id}"/>
			<c:param name="divName" value="${item.map.divName}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	    </c:url>

        <c:choose>
            <c:when test="${(index.count + 1) % 2 == 0}">
              <tr class="listEven">
            </c:when> 
            <c:otherwise>
              <tr class="listOdd">
            </c:otherwise>
        </c:choose>
          <td headers="Checkboxes" align="center">
            <input type="checkbox" name="mappings"
              onclick="update(this.form.mappings, this.form.selectAllPrograms);"
              value="<c:out value="${item.map.programId}:${item.map.divName}"/>">
          </td>
          <td headers="DivName"><c:out value="${item.map.divName}"/></td>

          <td headers="ProgramName">
            <c:out value="${item.map.programName}"/>
          </td>
          <td headers="Actions">
            <a href="<c:out value="${editUrl}"/>"><c:out value='${editImg}' escapeXml="false"/></a>
            <a href="<c:out value="${deleteUrl}"/>" onclick="return doDivMappingConfirmDelete();"><c:out value='${removeImg}' escapeXml="false"/></a>
          </td>
		</tr>
</c:forEach>

	  <!-- Empty DIV mapping message -->
<c:if test="${empty epChannelDivMappingsView.map.divMappings}">
        <tr class="listOdd">
          <td align="center" colspan="4">
            <bean-el:message key="ep.channel.div.mappings.noFound" bundle="ep.messages"/>
          </td>
        </tr>
</c:if>

	  </table>

	  </form>

</c:if>
<!-- End of DivMappings Section -->
    </td>
  </tr>
</table>

